<template>
    <el-dialog :center="false" :close-on-click-modal="false" :close-on-press-escape="false" :lock-scroll="true"
               :title="batchDialogTitle"
               top="20px" v-model="batchDialogTableVisible" width="80%">
        <el-row class="batch_row_btn">
            <el-button @click="handleAddDetails" size="mini" type="primary">
                <font-awesome-icon icon="plus-circle" style="color:#e3e9f2;"/>
                添加
            </el-button>
            <el-button @click="handleDeleteDetails" size="mini" type="success">
                <font-awesome-icon icon="trash" style="color:#e3e9f2;"/>
                删除
            </el-button>
            <el-button @click="handleDeleteAllDetails" size="mini" type="danger">
                <font-awesome-icon icon="trash-alt" style="color:#e3e9f2;"/>
                清空
            </el-button>
        </el-row>
        <el-table
                :data="batchDataList"
                :row-class-name="rowClassName"
                @selection-change="handleDetailSelectionChange"
                border
                fit="true"
                ref="tb"
                v-loading="loading"
        >
            <el-table-column align="center" type="selection" width="30"/>
            <el-table-column align="center" label="序号" prop="xh" width="50"></el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="主键"
                    prop="idUsersAudit"
                    required v-if=" false ">
                <template #default="scope">
                    <el-input-number clearable placeholder="请输入主键"
                                     v-model="batchDataList[scope.row.xh-1].idUsersAudit"/>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="主键"
                    prop="idUserinfo"
                    required v-if="true ">
                <template #default="scope">
                    <el-input-number clearable placeholder="请输入主键"
                                     v-model="batchDataList[scope.row.xh-1].idUserinfo"/>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="密码"
                    prop="password"
                    required v-if="true ">
                <template #default="scope">
                    <el-input clearable placeholder="请输入密码"
                              v-model="batchDataList[scope.row.xh-1].password"></el-input>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="生效日期"
                    prop="effectiveDate"
                    required v-if="true ">
                <template #default="scope">
                    <el-date-picker clearable placeholder="请选择生效日期"
                                    type="date"
                                    v-model="batchDataList[scope.row.xh-1].effectiveDate">
                    </el-date-picker>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="失效日期"
                    prop="expiredDate"
                    required v-if="true ">
                <template #default="scope">
                    <el-date-picker clearable placeholder="请选择失效日期"
                                    type="date"
                                    v-model="batchDataList[scope.row.xh-1].expiredDate">
                    </el-date-picker>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="备注"
                    prop="remark"
                    required v-if="true ">
                <template #default="scope">
                    <el-input clearable placeholder="请输入备注"
                              v-model="batchDataList[scope.row.xh-1].remark"></el-input>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="修改人"
                    prop="updatedBy"
                    v-if=" false ">
                <template #default="scope">
                    <el-input clearable placeholder="请输入修改人"
                              v-model="batchDataList[scope.row.xh-1].updatedBy"></el-input>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="修改日期"
                    prop="updatedDate"
                    v-if=" false ">
                <template #default="scope">
                    <el-date-picker clearable placeholder="请选择修改日期"
                                    type="date"
                                    v-model="batchDataList[scope.row.xh-1].updatedDate">
                    </el-date-picker>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="创建人"
                    prop="createdBy"
                    v-if=" false ">
                <template #default="scope">
                    <el-input clearable placeholder="请输入创建人"
                              v-model="batchDataList[scope.row.xh-1].createdBy"></el-input>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="创建日期"
                    prop="createdDate"
                    v-if=" false ">
                <template #default="scope">
                    <el-date-picker clearable placeholder="请选择创建日期"
                                    type="date"
                                    v-model="batchDataList[scope.row.xh-1].createdDate">
                    </el-date-picker>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="是否删除 1 是 0否"
                    prop="isDel"
                    v-if=" false ">
                <template #default="scope">
                    <el-input-number clearable placeholder="请输入是否删除 1 是 0否"
                                     v-model="batchDataList[scope.row.xh-1].isDel"/>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="状态名称"
                    prop="statusName"
                    v-if=" false ">
                <template #default="scope">
                    <el-input clearable placeholder="请输入状态名称"
                              v-model="batchDataList[scope.row.xh-1].statusName"></el-input>
                </template>
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="状态编码"
                    prop="statusCode"
                    required v-if="true ">
                <template #default="scope">
                    <el-input clearable placeholder="请输入状态编码"
                              v-model="batchDataList[scope.row.xh-1].statusCode"></el-input>
                </template>
            </el-table-column>
        </el-table>
        <el-row class="batch_submit_btn">
            <el-button @click="batchMerge()" size="small" type="primary">
                <font-awesome-icon icon="save" style="vertical-align: middle;color:#e3e9f2;"/>
                <span style="vertical-align: middle;">  提交 </span></el-button>
            <el-button @click="batchMergeDraft()" size="small" type="primary">
                <font-awesome-icon icon="save" style="vertical-align: middle;color:#e3e9f2;"/>
                <span style="vertical-align: middle;">  暂存 </span></el-button>
            <el-button @click="resetForm()" size="small">
                <font-awesome-icon icon="undo" style="vertical-align: middle;color:#e3e9f2;"/>
                <span style="vertical-align: middle;">  重置 </span></el-button>
        </el-row>
    </el-dialog>

    <el-dialog :center="false" :close-on-click-modal="false" :close-on-press-escape="false" :lock-scroll="true" :title="dialogTitle"
               top="20px" v-model="dialogTableVisible" width="80%">

        <el-form :model="ruleForm" :rules="rules" class="demo-ruleForm"  ref="ruleForm">
            <el-form-item label="主键" prop="idUsersAudit" v-if="false">
                <el-input clearable placeholder="请输入主键"
                          v-model="ruleForm.idUsersAudit"></el-input>
            </el-form-item>

            <el-form-item label="主键" prop="idUserinfo"
                          required v-if="!false">
                <el-input-number clearable placeholder="请输入主键"
                                 v-model="ruleForm.idUserinfo"/>
            </el-form-item>

            <el-form-item label="密码" prop="password"
                          required v-if="!false">
                <el-input clearable placeholder="请输入密码"
                          v-model="ruleForm.password"></el-input>
            </el-form-item>

            <el-form-item label="生效日期" prop="effectiveDate"
                          required v-if="!false">
                <el-date-picker clearable placeholder="请选择生效日期" type="date"
                                v-model="ruleForm.effectiveDate">
                </el-date-picker>
            </el-form-item>

            <el-form-item label="失效日期" prop="expiredDate"
                          required v-if="!false">
                <el-date-picker clearable placeholder="请选择失效日期" type="date"
                                v-model="ruleForm.expiredDate">
                </el-date-picker>
            </el-form-item>

            <el-form-item label="备注" prop="remark"
                          required v-if="!false">
                <el-input clearable placeholder="请输入备注"
                          v-model="ruleForm.remark"></el-input>
            </el-form-item>

            <el-form-item label="修改人" prop="updatedBy"
                          v-if="!true">
                <el-input clearable placeholder="请输入修改人"
                          v-model="ruleForm.updatedBy"></el-input>
            </el-form-item>

            <el-form-item label="修改日期" prop="updatedDate"
                          v-if="!true">
                <el-date-picker clearable placeholder="请选择修改日期" type="date"
                                v-model="ruleForm.updatedDate">
                </el-date-picker>
            </el-form-item>

            <el-form-item label="创建人" prop="createdBy"
                          v-if="!true">
                <el-input clearable placeholder="请输入创建人"
                          v-model="ruleForm.createdBy"></el-input>
            </el-form-item>

            <el-form-item label="创建日期" prop="createdDate"
                          v-if="!true">
                <el-date-picker clearable placeholder="请选择创建日期" type="date"
                                v-model="ruleForm.createdDate">
                </el-date-picker>
            </el-form-item>

            <el-form-item label="是否删除 1 是 0否" prop="isDel"
                          v-if="!true">
                <el-input-number clearable placeholder="请输入是否删除 1 是 0否"
                                 v-model="ruleForm.isDel"/>
            </el-form-item>

            <el-form-item label="状态名称" prop="statusName"
                          v-if="!true">
                <el-input clearable placeholder="请输入状态名称"
                          v-model="ruleForm.statusName"></el-input>
            </el-form-item>

            <el-form-item label="状态编码" prop="statusCode"
                          required v-if="!false">
                <el-select placeholder="请选择状态编码" v-model="ruleForm.statusCode">
                    <el-option
                            :key="sitem.statusCode"
                            :label="sitem.statusName"
                            :value="sitem.statusCode"
                            clearable
                            v-for="sitem in selectData"
                    >
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item>
                <table>
                    <tr>
                        <td>
                            <el-button @click="merge()" size="small" type="primary">
                                <font-awesome-icon icon="save" style="vertical-align: middle;color:#e3e9f2;"/>
                                <span style="vertical-align: middle;">  提交 </span></el-button>
                        </td>
                        <td>
                            <el-button @click="mergeDraft()" size="small" type="primary">
                                <font-awesome-icon icon="save" style="vertical-align: middle;color:#e3e9f2;"/>
                                <span style="vertical-align: middle;">  暂存 </span></el-button>
                        </td>
                        <td>
                            <el-button @click="resetForm()" size="small">
                                <font-awesome-icon icon="undo" style="vertical-align: middle;color:#e3e9f2;"/>
                                <span style="vertical-align: middle;">  重置 </span></el-button>
                        </td>
                    </tr>
                </table>
            </el-form-item>
        </el-form>
    </el-dialog>
    <el-dialog :center="false" :close-on-click-modal="false" :close-on-press-escape="false" :lock-scroll="true" title="查看数据"
               top="20px" v-model="viewVisible" width="80%">
        <el-form :model="ruleForm" class="view-ruleForm" label-width="15%" ref="ruleForm">
            <el-form-item label="主键" prop="idUsersAudit">
                <span>{{ruleForm.idUsersAudit}}</span>
            </el-form-item>
            <el-form-item label="主键" prop="idUserinfo">
                <span>{{ruleForm.idUserinfo}}</span>
            </el-form-item>
            <el-form-item label="密码" prop="password">
                <span>{{ruleForm.password}}</span>
            </el-form-item>
            <el-form-item label="生效日期" prop="effectiveDate">
                <span>{{ruleForm.effectiveDate}}</span>
            </el-form-item>
            <el-form-item label="失效日期" prop="expiredDate">
                <span>{{ruleForm.expiredDate}}</span>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
                <span>{{ruleForm.remark}}</span>
            </el-form-item>
            <el-form-item label="修改人" prop="updatedBy">
                <span>{{ruleForm.updatedBy}}</span>
            </el-form-item>
            <el-form-item label="修改日期" prop="updatedDate">
                <span>{{ruleForm.updatedDate}}</span>
            </el-form-item>
            <el-form-item label="创建人" prop="createdBy">
                <span>{{ruleForm.createdBy}}</span>
            </el-form-item>
            <el-form-item label="创建日期" prop="createdDate">
                <span>{{ruleForm.createdDate}}</span>
            </el-form-item>
            <el-form-item label="是否删除 1 是 0否" prop="isDel">
                <span>{{ruleForm.isDel}}</span>
            </el-form-item>
            <el-form-item label="状态名称" prop="statusName">
                <span>{{ruleForm.statusName}}</span>
            </el-form-item>
            <el-form-item label="状态编码" prop="statusCode">
                <span>{{ruleForm.statusCode}}</span>
            </el-form-item>
            <el-form-item>
                <el-button @click="this.viewVisible=!this.viewVisible" size="small" type="warning">关闭</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
    <div style="height: 100%">
        <!--查询区域-->
        <table class="inner_button">
            <tr>
                <td v-if="permission.add">
                    <el-button @click="btnOperation(1)" size="small" type="primary">
                        <font-awesome-icon icon="plus" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;"> 新增 </span>
                    </el-button>
                </td>
                <td v-if="permission.batchAdd">
                    <el-button @click="btnOperation(11)" size="small" type="primary">
                        <font-awesome-icon icon="plus-square" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;"> 批量新增 </span>
                    </el-button>
                </td>
                <td v-if="permission.edit">
                    <el-button @click="btnOperation(2)" size="small" type="primary">
                        <font-awesome-icon icon="edit" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;">  编辑 </span>
                    </el-button>
                </td>
                <td v-if="permission.view">
                    <el-button @click="btnOperation(3)" size="small" type="primary">
                        <font-awesome-icon icon="book-open" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;">  查看 </span>
                    </el-button>
                </td>
                <td v-if="permission.delete">
                    <el-button @click="btnOperation(4)" size="small" type="danger">
                        <font-awesome-icon icon="minus-square" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;">  删除 </span>
                    </el-button>
                </td>
                <td v-if="permission.view">
                    <el-button @click="btnOperation(5)" size="small" type="primary">
                        <font-awesome-icon icon="sync" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;">  刷新 </span>
                    </el-button>
                </td>
                <td v-if="permission.download">
                    <el-button @click="btnOperation(6)" size="small" type="primary">
                        <font-awesome-icon icon="file-download" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;">  下载模板 </span>
                    </el-button>
                </td>
                <td v-if="permission.execution">
                    <el-button @click="btnOperation(7)" size="small" type="primary">
                        <font-awesome-icon icon="play-circle" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;">  执行 </span>
                    </el-button>
                </td>
                <td v-if="permission.upload">
                    <el-upload
                            :auto-upload="true"
                            :on-change="upload"
                            :on-error="uploadError"
                            :on-progress="uploadProcess"
                            :on-success="uploadSuccess"
                            :show-file-list="false"
                            action="/system-config/system/usersAuditEntity/importData"
                            class="upload-demo"
                            name="file"
                    >
                        <el-button size="small" type="primary">
                            <font-awesome-icon icon="file-upload" style="vertical-align: middle;color:#e3e9f2;"/>
                            <span style="vertical-align: middle;">  上传 </span></el-button>
                    </el-upload>
                </td>
                <td v-if="permission.export">
                    <el-button @click="btnOperation(8)" size="small" type="primary">
                        <font-awesome-icon icon="file-export" style="vertical-align: middle;color:#e3e9f2;"/>
                        <span style="vertical-align: middle;">  导出 </span>
                    </el-button>
                </td>
            </tr>
        </table>

        <el-table
                :data="dataList"
                :row-key="getRowIdentity"
                @row-dblclick="editData"
                @selection-change="handleSelectionChange"
                border
                fit="true"
                highlight-current-row="true"
                id="usersAuditPo"
                ref="multipleTable"
                stripe="true"
                style="width: 100%;height:81%">
            <el-table-column fixed width="1"/>
            <el-table-column
                    :reserve-selection="true"
                    align="center"
                    type="selection"
            />
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="主键"
                    prop="idUsersAudit"
                    v-if=" false ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="主键"
                    prop="idUserinfo"
                    v-if="true ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="密码"
                    prop="password"
                    v-if="true ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="生效日期"
                    prop="effectiveDate"
                    v-if="true ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="失效日期"
                    prop="expiredDate"
                    v-if="true ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="备注"
                    prop="remark"
                    v-if="true ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="修改人"
                    prop="updatedBy"
                    v-if=" false ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="修改日期"
                    prop="updatedDate"
                    v-if=" false ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="创建人"
                    prop="createdBy"
                    v-if=" false ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="创建日期"
                    prop="createdDate"
                    v-if=" false ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="是否删除 1 是 0否"
                    prop="isDel"
                    v-if=" false ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="状态名称"
                    prop="statusName"
                    v-if="true ">
            </el-table-column>
            <el-table-column
                    :formatter="dataFormat"
                    :show-overflow-tooltip="true"
                    label="状态编码"
                    prop="statusCode"
                    v-if=" false ">
            </el-table-column>
        </el-table>
        <el-pagination
                :current-page="currentPage"
                :page-count="totalPage"
                :page-size="pageSize"
                :page-sizes="[20,50, 100, 150, 200]"
                :total="totalData"
                @current-change="pageChangeClick"
                @next-click="pageClick(2)"
                @prev-click="pageClick(1)"
                @size-change="pageSizeClick"
                current-page="当前页"
                jumper-text="跳转"
                layout="total, sizes, prev, pager, next, jumper"
                next-text="下一页"
                prev-text="上一页">
        </el-pagination>
    </div>
</template>
<style>

</style>
<script>
    import axios from "axios";
    import {ElLoading} from "element-plus"
    import {confirm, error, success, warning} from "../../utils/message";
    import {download, permissionResources} from "../../api/star_horse";

    export default {
        name: "UsersAuditEntity",
        setup() {
            return {}
        },
        data() {
            return {
                loading: null,
                batchDialogTitle: "",
                batchDialogTableVisible: false,
                dialogTableVisible: false,
                uploadVisible: false,
                viewVisible: false,
                dialogTitle: "",
                ruleForm: {},
                dataList: [],
                permission: {view: "view"},
                checkedDetail: [],
                batchDataList: [],
                selectData: [],
                currentPage: 1,
                pageSize: 20,
                totalPage: 0,
                totalData: 0,
                rules: {}
            }
        },
        methods: {
            rowClassName({row, rowIndex}) {
                row.xh = rowIndex + 1;
            },
            //单选框选中数据
            handleDetailSelectionChange(selection) {
                if (selection.length > 1) {
                    this.$refs.tb.clearSelection();
                    this.$refs.tb.toggleRowSelection(selection.pop());
                } else {
                    this.checkedDetail = selection;
                }
            },
            handleAddDetails() {
                if (this.batchDataList == undefined) {
                    this.batchDataList = new Array();
                }
                let obj = {};
                obj.idUsersAudit = "";
                obj.idUserinfo = "";
                obj.password = "";
                obj.effectiveDate = "";
                obj.expiredDate = "";
                obj.remark = "";
                obj.updatedBy = "";
                obj.updatedDate = "";
                obj.createdBy = "";
                obj.createdDate = "";
                obj.isDel = "";
                obj.statusName = "";
                obj.statusCode = "";
                this.batchDataList.push(obj);
            },
            handleDeleteDetails() {
                if (this.checkedDetail.length == 0) {
                    warning("请先选择要删除的数据");
                } else {
                    this.batchDataList.splice(this.checkedDetail[0].xh - 1, 1);
                }
            },
            handleDeleteAllDetails() {
                this.batchDataList = [];
            },
            dataFormat(row, column, cellValue, index) {
                if (!cellValue) {
                    return "-";
                }
                if (column.property == "createdDate" || column.property == "updatedDate") {
                    let date = new Date(cellValue);
                    return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
                } else {
                    return cellValue;
                }
            },
            /**
             * 加载框
             */
            load(msg) {
                if (!this.loading) {
                    this.loading = ElLoading.service({
                        lock: true,
                        target: "#usersAuditPo",
                        text: msg || 'Loading',
                        background: 'rgba(0, 0, 0, 0.7)',
                    });
                } else {
                    this.loading.open();
                }
            }
            ,
            closeLoad() {
                if (this.loading) {
                    this.loading.close();
                    this.loading = null;
                }
            }
            ,
            getRowIdentity(row) {
                return row[this.getIdName()];
            }
            ,
            getIdName() {
                return "idUsersAudit";
            },
            /**
             * 按钮操作
             */
            btnOperation(type) {
                this.closeLoad();
                switch (type) {
                    //新增编辑
                    case 1:
                        this.ruleForm = {};
                        this.dialogTableVisible = !this.dialogTableVisible;
                        this.dialogTitle = "新增数据";
                        break;
                    case 11:
                        this.batchDataList = [];
                        this.batchDialogTableVisible = !this.batchDialogTableVisible;
                        this.batchDialogTitle = "批量新增";
                        break;
                    case 2:
                        this.ruleForm = {};
                        if (this.multipleSelection.length < 1) {
                            this.warning("至少需要选择一条要编辑的数据");
                            return;
                        }
                        this.dialogTableVisible = !this.dialogTableVisible;
                        this.dialogTitle = "编辑数据";
                        this.loadById(this.multipleSelection[0][this.getIdName()]);
                        // this.$refs.multipleTable.clearSelection();
                        break;
                    //查看
                    case 3:
                        if (this.multipleSelection.length != 1) {
                            this.warning("查看数据只能选择一条");
                            return;
                        }
                        this.viewVisible = true;
                        this.loadById(this.multipleSelection[0][this.getIdName()]);
                        break;
                    //删除
                    case 4:
                        this.delete()
                        break;
                    //刷新
                    case 5:
                        this.loadByPage(1, this.pageSize);
                        break;
                    //下载模板
                    case 6:
                        this.downloadTemplate();
                        break;
                    //导出
                    case 8:
                        this.exportAll();
                        break;
                    default:
                        throw error("未知类型");
                }
            }
            ,
            pageClick(type) {
                this.loadByPage(this.currentPage, this.pageSize);
            }
            ,
            pageSizeClick(pageSize) {
                this.pageSize = pageSize;
                this.loadByPage(this.currentPage, pageSize);
            }
            ,
            pageChangeClick(currentPage) {
                this.currentPage = currentPage;
                this.loadByPage(this.currentPage, this.pageSize);
            }
            ,
            editData(row, column, event) {
                this.viewVisible = !this.viewVisible;
                this.loadById(row[this.getIdName()]);
            }
            ,
            //重置数据
            resetForm() {
                this.ruleForm = {};
                this.batchDataList = [];
            }
            ,
            //处理选中的数据
            handleSelectionChange(val) {
                this.multipleSelection = val;
            }
            ,
            /**
             * 初始化数据
             */
            init: function () {
                this.dataList = [];
                this.selectData = [];
                this.loadByPage(this.currentPage, this.pageSize);
                this.loadPermissionResources();
                this.loadSelectData();

            },
            /**
             * 加载资源权限
             */
            loadPermissionResources() {
                let that = this;
                let meta = that.$router.currentRoute.value.meta;
                let data = {"menuId": meta.menuId};
                permissionResources(data).then(res => {
                    let redata = res.data.data;
                    redata.forEach(item => {
                        that.permission[item.resCode] = item.resCode;
                    });
                });
            },
            /**
             * 状态码数据
             */
            loadSelectData() {
                let that = this;
                let query = [];
                query.push({
                    "propertyName": "statusType",
                    "value": "sys_users_audit"
                })
                axios.post("/system-config/system/statusinfoEntity/getAllByCondition", query).then(res => {
                    let redata = res.data;
                    that.selectData = redata.data;
                }).catch(err => {
                    error(err);
                });
            }
            ,
            /**
             * 分页显示数据
             */
            loadByPage: function (currentPage, pageSize) {
                let that = this;
                this.load();
                axios.post("/system-config/system/usersAuditEntity/pageList", {
                    currentPage: currentPage < 1 ? 1 : currentPage,
                    pageSize: pageSize || that.pageSize
                }).then(res => {
                    let redata = res.data.data;
                    that.dataList = redata.dataList;
                    that.totalPage = redata.totalPages;
                    that.currentPage = redata.currentPage;
                    that.totalData = redata.totalDatas;
                }).catch(err => {
                    error(err);
                }).finally(() => {
                    that.closeLoad();
                })
            }
            ,
            /**
             * 刷新数据
             */
            refresh: function () {
                this.init();
            }
            ,
            /**
             * 编辑保存数据
             */
            merge: function () {
                let flag = false;
                let that = this;
                that.$refs.ruleForm.validate((valid) => {
                    flag = valid;
                });
                if (!flag) {
                    return;
                }
                that.load();
                let statusCode = that.ruleForm.statusCode;
                if (statusCode && that.selectData && that.selectData.length > 0) {
                    let sData = that.selectData.find(item => item.statusCode === statusCode);
                    that.ruleForm.statusName = sData.statusName;
                }
                axios.post("/system-config/system/usersAuditEntity/merge", that.ruleForm).then(res => {
                    success(res.data.cnMessage);
                    that.closeLoad();
                    that.loadByPage(1, that.pageSize);
                    that.ruleForm = {};
                    that.dialogTableVisible = !that.dialogTableVisible;
                }).catch(err => {
                    error(err);
                }).finally(() => {
                    that.closeLoad();
                })
            }
            ,
            /**
             * 编辑保存数据
             */
            mergeDraft: function () {
                let that = this;
                this.load();
                let statusCode = that.ruleForm.statusCode;
                if (statusCode && that.selectData && that.selectData.length > 0) {
                    let sData = that.selectData.find(item => item.statusCode === statusCode);
                    that.ruleForm.statusName = sData.statusName;
                }
                axios.post("/system-config/system/usersAuditEntity/mergeDraft", that.ruleForm).then(res => {
                    success(res.data.cnMessage);
                    that.closeLoad();
                    that.loadByPage(1, this.pageSize);
                    that.ruleForm = {};
                    that.dialogTableVisible = !that.dialogTableVisible;
                }).catch(err => {
                    error(err);
                }).finally(() => {
                    that.closeLoad();
                })
            }
            ,
            /**
             * 批量编辑保存数据
             */
            batchMerge: function () {
                let that = this;
                this.load();
                axios.post("/system-config/system/usersAuditEntity/mergeBatch", that.batchDataList).then(res => {
                    success(res.data.cnMessage);
                    that.closeLoad();
                    that.loadByPage(1, this.pageSize);
                    that.batchDataList = [];
                    that.batchDialogTableVisible = !that.batchDialogTableVisible;
                }).catch(err => {
                    error(err);
                }).finally(() => {
                    that.closeLoad();
                })
            }
            ,
            /**
             * 批量编辑保存草稿数据
             */
            batchMergeDraft: function () {
                let that = this;
                this.load();
                axios.post("/system-config/system/usersAuditEntity/mergeBatchDraft", that.batchDataList).then(res => {
                    success(res.data.cnMessage);
                    that.closeLoad();
                    that.loadByPage(1, this.pageSize);
                    that.batchDataList = [];
                    that.batchDialogTableVisible = !that.batchDialogTableVisible;
                }).catch(err => {
                    error(err);
                }).finally(() => {
                    that.closeLoad();
                })
            }
            ,
            /**
             * 获取已选中数据的Id
             */
            getSelectedData() {
                let ids = [];
                this.multipleSelection.forEach(item => ids.push(item[this.getIdName()]));
                return ids;
            }
            ,
            /**
             * 加载指定数据
             */
            loadById: function (id) {
                let that = this;
                that.load();
                axios.get("/system-config/system/usersAuditEntity/getById/" + id).then(res => {
                    that.ruleForm = res.data.data;
                }).catch(err => {
                    error(err);
                }).finally(() => {
                    that.closeLoad();
                })
            }
            ,
            /**
             * 删除数据
             */
            delete: function () {
                let that = this;
                if (this.multipleSelection.length == 0) {
                    this.warning("请选择要删除的数据");
                    return;
                }
                this.load();
                confirm("确认需要删除选择的数据吗？", function () {
                    axios.post("/system-config/system/usersAuditEntity/batchDeleteByIdLogic", that.getSelectedData()).then(res => {
                        success(res.data.cnMessage);
                        that.multipleSelection = [];
                        that.closeLoad();
                        that.loadByPage(that.currentPage, that.pageSize);
                    }).catch(err => {
                        error(err)
                    }).finally(() => {
                        that.closeLoad();
                    })
                })

            }
            ,
            /**
             * 上传数据
             */
            upload: function (file, fileList) {

            }
            ,
            /**
             * 上传过程
             */
            uploadProcess: function (event, file, fileList) {
                this.load("数据导入中,请等待");
            }
            ,
            /**
             * 上传失败
             */
            uploadError: function (error, file, fileList) {
                this.closeLoad();
            }
            ,
            /**
             * 上传成功
             */
            uploadSuccess: function (response, file, fileList) {
                this.success(response.cnMessage);
                this.closeLoad();
                this.init();
            }
            ,
            /**
             * 导出所有数据
             */
            exportAll: function () {
                let that = this;
                that.load();
                download("/system-config/system/usersAuditEntity/exportData", that.getSelectedData()).catch(err => {
                    error(err);
                }).finally(() => {
                    that.closeLoad();
                })
            }
            ,
            /**
             * 下载模板
             */
            downloadTemplate: function () {
                let that = this;
                download("/system-config/system/usersAuditEntity/downloadTemplate", {}).catch(error => {
                    that.error(error);
                });
            }
        },
        created() {
            this.init();
        }
    }
</script>